/*
 * File:   TestComparer.cpp
 * Author: marco
 *
 * Created on December 8, 2009, 2:36 PM
 */

#include <alg/InPlaceComparer.h>
#include <alg/IteratorComparer.h>
#include <gtest/gtest.h>

TEST(ComparerTest, TestInPlace) {
    std::vector<int> v;
    v.push_back(1);
    v.push_back(2);
    alg::InPlaceComparer<std::vector<int> > comparer(v);
    EXPECT_TRUE(comparer.isLess(0,1));
    EXPECT_FALSE(comparer.isLess(1,0));
}

//TEST(ComparerTest, TestInPlace2) {
//    std::vector<int> v;
//    v.push_back(2);
//    v.push_back(1);
//    alg::InPlaceComparer<std::vector<int> > comparer(v);
//    EXPECT_FALSE(comparer.isLess(0,1));
//    EXPECT_TRUE(comparer.isLess(1,0));
//}

TEST(ComparerTest, TestIterator) {
    std::vector<int> v;
    v.push_back(1);
    v.push_back(2);
    alg::IteratorComparer<std::vector<int> > comparer(v);
    std::vector<int>::iterator i = v.begin();
    EXPECT_FALSE(comparer.isLess(0, i - v.begin()));
    ++i;
    EXPECT_TRUE(comparer.isLess(0, i - v.begin()));
}
